<?php

echo '<form action="index.php" method="POST"><input type=submit value=Anuluj class="butt4"></form>';


$sql="select * from sl_gab";
$result=mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$sl_gab[$row['id']]=$row['nazwa'];
}


	require("./ajax/forms.php");
	require("./ajax/form_layout_vertical.php");
	require("./ajax/form_layout_paged.php");
	require("./ajax/form_animation.php");

	$form=new form_class;
	$form->encoding="utf-8";
	$form->NAME="subscription_form";
	$form->METHOD="POST";
	$form->ACTION="";
	$form->debug="trigger_error";
	$form->ResubmitConfirmMessage='xx';
	$form->OutputPasswordValues=1;
	$form->OptionsSeparator="<br>\n";
	$form->ShowAllErrors=1;
	$form->InvalidCLASS='butt4';

	
	$form->AddInput(array(
		"TYPE"=>"text",
		"NAME"=>"login",
		"ID"=>"login",
		"MAXLENGTH"=>30,
		"SIZE"=>21,
		"ValidateAsNotEmpty"=>1,
		"ValidationErrorMessage"=>
			"Brak nazwy użytkownika",
		"LABEL"=>"Nazwa użytkownika",
		"ACCESSKEY"=>"I",
		
	));
	
	$form->AddInput(array(
		"TYPE"=>"text",
		"NAME"=>"nazwisko",
		"ID"=>"nazwisko",
		"MAXLENGTH"=>30,
		"SIZE"=>21,
		"Capitalization"=>"uppercase",
		"ValidateAsNotEmpty"=>1,
		"ValidationErrorMessage"=>
			"Brak nazwiska",
		"LABEL"=>"Nazwisko",
		"ACCESSKEY"=>"I",
		
	));
	
	$form->AddInput(array(
		"TYPE"=>"text",
		"NAME"=>"imie",
		"ID"=>"imie",
		"MAXLENGTH"=>25,
		"SIZE"=>16,
		"Capitalization"=>"uppercase",
		"ValidateAsNotEmpty"=>1,
		"ValidationErrorMessage"=>
			"Brak imienia",
		"LABEL"=>"Imię",
		"ACCESSKEY"=>"I",
		
	));
	
	$form->AddInput(array(
		"TYPE"=>"password",
		"NAME"=>"haslo",
		"ID"=>"haslo",
		"MAXLENGTH"=>15,
		"SIZE"=>16,
		"ValidateAsNotEmpty"=>1,
		"ValidationErrorMessage"=>
			"Brak hasła",
		"LABEL"=>"Hasło",
		"ACCESSKEY"=>"I",
		
	));
	
	$form->AddInput(array(
		"TYPE"=>"select",
		
		"NAME"=>"gabinety",
		"ID"=>"gabinety",
		"VALUE"=>"2",
		"SIZE"=>8,
		"OPTIONS"=>$sl_gab,
		"ValidationErrorMessage"=>
			"Brak wybranego gabinetu",
		"LABEL"=>"Gabinet",
		
	));
	
	
	$form->AddInput(array(
		"TYPE"=>"text",
		"NAME"=>"haslo_do",
		"ID"=>"haslo_do",
		"MAXLENGTH"=>10,
		"SIZE"=>11,
		"Capitalization"=>"uppercase",
		"ValidateAsNotEmpty"=>1,
		"ValidationErrorMessage"=>
			"Brak daty ważności hasła",
		"LABEL"=>"Ważnośc hasła",
		"ACCESSKEY"=>"I",
		"VALUE"=>date("Y-m-d", strtotime("+30 days"))
	));
		$form->AddInput(array(
		"TYPE"=>"checkbox",
		"NAME"=>"akt",
		"ID"=>"akt",
		"LABEL"=>"Aktywny",
		"ACCESSKEY"=>"I",
		"CHECKED"=>1
	));
	
	

		$form->AddInput(array(
		"TYPE"=>"submit",
		"ID"=>"button_subscribe",
		"NAME"=>"user_new_zap",
		"VALUE"=>"Zapisz",
		"ACCESSKEY"=>"u"
	));
	$form->AddInput(array(
		"TYPE"=>"image",
		"ID"=>"image_subscribe",
		"NAME"=>"grafik_dod_b",
		"SRC"=>"http://www.phpclasses.org/graphics/add.gif",
		"ALT"=>"Submit subscription",
		"STYLE"=>"border-width: 0px;"
	));

	
	$form->AddInput(array(
		"TYPE"=>"hidden",
		"NAME"=>"user_track",
		"VALUE"=>"1",
		"ValidateAsInteger"=>1,
		"DiscardInvalidValues"=>1
	));

/*
 * Add several vertical layout inputs to automatically layout all inputs
 * in each page without additional HTML templates.
 */
	$form->AddInput(array(
		'ID'=>'personal',
		'NAME'=>'personal',
		'TYPE'=>'custom',
		"CustomClass"=>"form_layout_vertical_class",
		'Inputs'=>array(
			'login',
			'nazwisko',
			'imie',
			'haslo',
			'gabinety',
			'haslo_do',
			'akt'
			),
		'Data'=>array(
			'separator'=>'<tr><td colspan="2"><hr /></td></tr>',
		),
		
		
		'InvalidMark'=>'[Wpisz]',
		'InputFormat'=>
			'<tr><th align="right">{label}:</th><td valign="top">{input}&nbsp;{mark}</td></tr>',
	));
	
/*
 * Add a paged layout input to layout the pages of inputs
 */
	$form->AddInput(array(
		'ID'=>'layout',
		'NAME'=>'layout',
		'TYPE'=>'custom',
		'CustomClass'=>'form_layout_paged_class',
		'Pages'=>array(
			'personal'=>array(
				'Name' => 'Dodanie użytkownika'
			),
			
		),
		'AutoAdjustSize'=>0,
		'FadePagesTime'=>0.25
	));

/*
 * Load form input values eventually from the submitted form.
 */
	$form->LoadInputValues($form->WasSubmitted());

/*
 * Empty the array that will list the values with invalid field after
 * validation.
 */
	$verify=array();

/*
 * Check if the global array variable corresponding to hidden input field
 * is defined, meaning that the form was submitted as opposed to being
 * displayed for the first time.
 */
	if($form->WasSubmitted())
	{


/*
 * Therefore we need to validate the submitted form values.
 */
		if(($error_message=$form->Validate($verify))=="")
		{

/*
 * It's valid, set the $doit flag variable to 1 to tell the form is ready
 * to processed.
 */
			$doit=1;
			

		}
		else
		{

/*
 * It's invalid, set the $doit flag to 0 and encode the returned error
 * message to escape any non-ASCII ISO-latin 1 characters and HTML special
 * characters.
 */
			$doit=0;
			$error_message=nl2br(HtmlSpecialChars($error_message));
		}
	}
	else
	{

/*
 * The form is being displayed for the first time, so it is not ready to
 * be processed and there is no error message to display.
 */
		$error_message="";
		$doit=0;
	}
  if($doit)
  {

/*
 * The form is ready to be processed, just output it again as read only to
 * display the submitted values.  A real form processing script usually
 * may do something else like storing the form values in a database.
 */
  	$form->ReadOnly=1;
  }

	if(!$doit)
	{
		if(strlen($error_message))
		{
			Reset($verify);
			$focus=Key($verify);
		}
		else
			$focus='login';
		$form->ConnectFormToInput($focus, 'ONLOAD', 'Focus', array());
	}

	$onload=HtmlSpecialChars($form->PageLoad());

?>
<?php
	echo $form->PageHead();
?>
</head>
<body onload="<?php	echo $onload; ?>">

<?php

/*
 * Compose the form output by including a HTML form template with PHP code
 * interleaved with calls to insert form input field parts in the layout
 * HTML.
 */

	$form->StartLayoutCapture();
	$title="Dodanie użytkownika";
	$body_template="form_paged_layout_body.html.php";
	require("./ajax/templates/form_frame.html.php");
	$form->EndLayoutCapture();

/*
 * Output the form using the function named Output.
 */
	$form->DisplayOutput();
?>
